import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
var _excluded = ["__id", "_status", "serviceName"],
    _excluded2 = ["__id", "_status"],
    _excluded3 = ["__id", "_status"];

/**
 * @creationDate 2019/11/21
 */
import intl from 'utils/intl';
import React from 'react';
import { getAccessToken } from 'utils/utils';
import { CPAAS_IAM, CPAAS_PLATFORM, API_HOST } from 'utils/config';
import { getMenuId } from 'utils/menuTab';
import { Icon, Tooltip } from 'antd';
export var sysToolsCacheAxiosConfig = function sysToolsCacheAxiosConfig() {
  return {
    cpfm: {
      'code-rule': function codeRule() {
        return {
          url: "".concat(CPAAS_PLATFORM, "/v1/tool/cache/code-rule"),
          method: 'POST',
          data: {},
          baseURL: "".concat(API_HOST),
          headers: {
            Authorization: "bearer ".concat(getAccessToken()),
            'H-Menu-Id': "".concat(getMenuId())
          }
        };
      },
      config: function config() {
        return {
          url: "".concat(CPAAS_PLATFORM, "/v1/tool/cache/config"),
          method: 'POST',
          data: {},
          baseURL: "".concat(API_HOST),
          headers: {
            Authorization: "bearer ".concat(getAccessToken()),
            'H-Menu-Id': "".concat(getMenuId())
          }
        };
      },
      database: function database() {
        return {
          url: "".concat(CPAAS_PLATFORM, "/v1/tool/cache/database"),
          method: 'POST',
          data: {},
          baseURL: "".concat(API_HOST),
          headers: {
            Authorization: "bearer ".concat(getAccessToken()),
            'H-Menu-Id': "".concat(getMenuId())
          }
        };
      },
      datasource: function datasource() {
        return {
          url: "".concat(CPAAS_PLATFORM, "/v1/tool/cache/datasource"),
          method: 'POST',
          data: {},
          baseURL: "".concat(API_HOST),
          headers: {
            Authorization: "bearer ".concat(getAccessToken()),
            'H-Menu-Id': "".concat(getMenuId())
          }
        };
      },
      customize: function customize() {
        return {
          url: "".concat(CPAAS_PLATFORM, "/v1/ui-customize/refreshCache"),
          method: 'get',
          data: {},
          baseURL: "".concat(API_HOST),
          headers: {
            Authorization: "bearer ".concat(getAccessToken()),
            'H-Menu-Id': "".concat(getMenuId())
          }
        };
      },
      'entity-table': function entityTable() {
        return {
          url: "".concat(CPAAS_PLATFORM, "/v1/tool/cache/entity-table"),
          method: 'POST',
          data: {},
          baseURL: "".concat(API_HOST),
          headers: {
            Authorization: "bearer ".concat(getAccessToken()),
            'H-Menu-Id': "".concat(getMenuId())
          }
        };
      },
      'permission-range': function permissionRange() {
        return {
          url: "".concat(CPAAS_PLATFORM, "/v1/tool/cache/permission-range"),
          method: 'POST',
          data: {},
          baseURL: "".concat(API_HOST),
          headers: {
            Authorization: "bearer ".concat(getAccessToken()),
            'H-Menu-Id': "".concat(getMenuId())
          }
        };
      },
      profile: function profile() {
        return {
          url: "".concat(CPAAS_PLATFORM, "/v1/tool/cache/profile"),
          method: 'POST',
          data: {},
          baseURL: "".concat(API_HOST),
          headers: {
            Authorization: "bearer ".concat(getAccessToken()),
            'H-Menu-Id': "".concat(getMenuId())
          }
        };
      },
      prompt: function prompt() {
        return {
          url: "".concat(CPAAS_PLATFORM, "/v1/tool/cache/prompt"),
          method: 'POST',
          data: {},
          baseURL: "".concat(API_HOST),
          headers: {
            Authorization: "bearer ".concat(getAccessToken()),
            'H-Menu-Id': "".concat(getMenuId())
          }
        };
      },
      message: function message() {
        return {
          url: "".concat(CPAAS_PLATFORM, "/v1/tool/cache/return-message"),
          method: 'POST',
          data: {},
          baseURL: "".concat(API_HOST),
          headers: {
            Authorization: "bearer ".concat(getAccessToken()),
            'H-Menu-Id': "".concat(getMenuId())
          }
        };
      }
    },
    ciam: {
      client: function client() {
        return {
          url: "".concat(CPAAS_IAM, "/v1/tool/cache/client"),
          data: {},
          method: 'POST',
          baseURL: "".concat(API_HOST),
          headers: {
            Authorization: "bearer ".concat(getAccessToken()),
            'H-Menu-Id': "".concat(getMenuId())
          }
        };
      },
      ldap: function ldap() {
        return {
          url: "".concat(CPAAS_IAM, "/v1/tool/cache/ldap"),
          data: {},
          method: 'POST',
          baseURL: "".concat(API_HOST),
          headers: {
            Authorization: "bearer ".concat(getAccessToken()),
            'H-Menu-Id': "".concat(getMenuId())
          }
        };
      },
      user: function user() {
        return {
          url: "".concat(CPAAS_IAM, "/v1/tool/cache/user"),
          data: {},
          method: 'POST',
          baseURL: "".concat(API_HOST),
          headers: {
            Authorization: "bearer ".concat(getAccessToken()),
            'H-Menu-Id': "".concat(getMenuId())
          }
        };
      },
      domain: function domain() {
        return {
          url: "".concat(CPAAS_IAM, "/v1/tool/cache/domain"),
          data: {},
          method: 'POST',
          baseURL: "".concat(API_HOST),
          headers: {
            Authorization: "bearer ".concat(getAccessToken()),
            'H-Menu-Id': "".concat(getMenuId())
          }
        };
      },
      'open-app': function openApp() {
        return {
          url: "".concat(CPAAS_IAM, "/v1/tool/cache/open-app"),
          data: {},
          method: 'POST',
          baseURL: "".concat(API_HOST),
          headers: {
            Authorization: "bearer ".concat(getAccessToken()),
            'H-Menu-Id': "".concat(getMenuId())
          }
        };
      },
      'password-policy': function passwordPolicy() {
        return {
          url: "".concat(CPAAS_IAM, "/v1/tool/cache/password-policy"),
          data: {},
          method: 'POST',
          baseURL: "".concat(API_HOST),
          headers: {
            Authorization: "bearer ".concat(getAccessToken()),
            'H-Menu-Id': "".concat(getMenuId())
          }
        };
      }
    }
  };
};
export var sysToolsPermissionAxiosConfig = function sysToolsPermissionAxiosConfig() {
  return {
    ciam: {
      'assign-super-role': function assignSuperRole() {
        return {
          url: "".concat(CPAAS_IAM, "/v1/tool/permission/assign-super-role"),
          method: 'POST',
          data: {},
          baseURL: "".concat(API_HOST),
          headers: {
            Authorization: "bearer ".concat(getAccessToken()),
            'H-Menu-Id': "".concat(getMenuId())
          }
        };
      },
      'assign-inherit-role': function assignInheritRole(data) {
        return {
          url: "".concat(CPAAS_IAM, "/v1/tool/permission/assign-inherit-role"),
          method: 'POST',
          params: data || {},
          baseURL: "".concat(API_HOST),
          headers: {
            Authorization: "bearer ".concat(getAccessToken()),
            'H-Menu-Id': "".concat(getMenuId())
          }
        };
      },
      fresh: function fresh(data) {
        return {
          url: "".concat(CPAAS_IAM, "/v1/tool/permission/fresh"),
          method: 'POST',
          data: data || {},
          baseURL: "".concat(API_HOST),
          headers: {
            Authorization: "bearer ".concat(getAccessToken()),
            'H-Menu-Id': "".concat(getMenuId())
          }
        };
      }
    }
  };
};
export var sysToolsPermissionFreshDS = function sysToolsPermissionFreshDS() {
  return {
    autoQueryAfterSubmit: false,
    autoCreate: true,
    fields: [{
      label: intl.get('cpfm.sysTools.model.refreshPermission.serviceName').d('服务名'),
      name: 'serviceName',
      type: 'object',
      lovCode: 'CADM.INSTANCE',
      required: true
    }, {
      // eslint-disable-next-line react/react-in-jsx-scope
      label: /*#__PURE__*/React.createElement(React.Fragment, null, intl.get('cpfm.sysTools.model.refreshPermission.metaVersion').d('服务标记版本'), /*#__PURE__*/React.createElement(Tooltip, {
        title: intl.get('cpfm.sysTools.view.message.title.metaVersion.tooptip').d('不输入版本是刷新最新版本')
      }, /*#__PURE__*/React.createElement(Icon, {
        type: "question-circle"
      }))),
      name: 'metaVersion',
      type: 'string'
    }, {
      // boolean 值不需要 required(一定会有值)
      label: intl.get('cpfm.sysTools.model.refreshPermission.cleanPermission').d('清除过期权限'),
      name: 'cleanPermission',
      type: 'boolean',
      defaultValue: true
    }],
    transport: {
      create: function create(_ref) {
        var data = _ref.data;

        var _data = _slicedToArray(data, 1),
            _data$ = _data[0],
            __id = _data$.__id,
            _status = _data$._status,
            serviceName = _data$.serviceName,
            rest = _objectWithoutProperties(_data$, _excluded);

        var url = "".concat(CPAAS_IAM, "/v1/tool/permission/fresh");
        return {
          url: url,
          method: 'POST',
          params: _objectSpread(_objectSpread({}, rest), {}, {
            serviceName: serviceName.service
          }),
          data: {}
        };
      }
    }
  };
};
export var sysToolsPermissionAssignInheritRoleDS = function sysToolsPermissionAssignInheritRoleDS() {
  return {
    autoQueryAfterSubmit: false,
    fields: [{
      label: intl.get('cpfm.sysTools.model.refreshPermission.roleLevelPaths').d('角色路径'),
      name: 'roleLevelPaths',
      type: 'string'
    }],
    transport: {
      create: function create(_ref2) {
        var data = _ref2.data;

        var _data2 = _slicedToArray(data, 1),
            _data2$ = _data2[0],
            __id = _data2$.__id,
            _status = _data2$._status,
            rest = _objectWithoutProperties(_data2$, _excluded2);

        var url = "".concat(CPAAS_IAM, "/v1/tool/permission/assign-inherit-role");
        return {
          url: url,
          method: 'POST',
          params: rest,
          data: {}
        };
      }
    }
  };
};
export var sysToolsPasswordPolicyEncryptDS = function sysToolsPasswordPolicyEncryptDS() {
  return {
    autoQueryAfterSubmit: false,
    autoCreate: true,
    fields: [{
      label: intl.get('cpfm.sysTools.model.passwordPolicy.pass').d('密码'),
      name: 'pass',
      type: 'string',
      required: true
    }, {
      label: intl.get('cpfm.sysTools.model.passwordPolicy.encryptPass').d('加密密码'),
      name: 'encryptPass',
      type: 'string',
      readOnly: true
    }],
    transport: {
      create: function create(_ref3) {
        var data = _ref3.data;

        var _data3 = _slicedToArray(data, 1),
            _data3$ = _data3[0],
            __id = _data3$.__id,
            _status = _data3$._status,
            rest = _objectWithoutProperties(_data3$, _excluded3);

        var url = "".concat(CPAAS_PLATFORM, "/v1/tool/pass/encrypt");
        return {
          url: url,
          method: 'POST',
          params: rest,
          data: {}
        };
      }
    }
  };
};
export var sysToolsPasswordPolicyAxiosConfig = function sysToolsPasswordPolicyAxiosConfig() {
  return {
    cpfm: {
      'public-key': function publicKey() {
        return {
          url: "".concat(CPAAS_PLATFORM, "/v1/tool/pass/public-key"),
          method: 'GET',
          baseURL: "".concat(API_HOST),
          headers: {
            Authorization: "bearer ".concat(getAccessToken()),
            'H-Menu-Id': "".concat(getMenuId())
          }
        };
      }
    }
  };
};